<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>停奶</title>
		<link href="../css/mui.min.css" rel="stylesheet" type="text/css">
		<link href="../css/home.page.css" rel="stylesheet" />
		<link href="../bootstrap-select/bootstrap-select.css" rel="stylesheet">
		<link href="../css/bootstrap.min.css" rel="stylesheet" >
		<link href="../css/mui.picker.min.css" rel="stylesheet" >
		<script charset="UTF-8" src="../js/jquery.min.js"></script>
		<script charset="UTF-8" src="../js/config.js"></script>
		<script charset="UTF-8" src="../js/core.js"></script>
		<script charset="UTF-8" src="../js/cipher-core.js"></script>
		<script charset="UTF-8" src="../js/tripledes.js"></script>
		<script charset="UTF-8" src="../js/mode-ecb.js"></script>
		<script charset="UTF-8" src="../js/zepto.min.js"></script>
		<script charset="UTF-8" src="../js/spin.min.js"></script>
		<script charset="UTF-8" src="../js/mui.min.js"></script>
		<script charset="UTF-8" src="../js/testActivityName.js"></script>
		<script charset="UTF-8" src="../js/simple.tool.js"></script>
		<script charset="UTF-8" src="../js/mui.picker.min.js"></script>
		<style>
			label{
				text-align: right;
			}
			.btn-default{
				border-color: snow;
			}
			.form-control{
				-webkit-box-shadow: inset 0 0px 0px rgba(0,0,0,.075);
			}
			.form-group{
				border-bottom: 1px solid #f6f6f6;max-width: 720px;height: 55px;
			}
		</style>
	</head>
	<body class="white-bg" >
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" style="width: 95%;" id="form-milkcut-add" target="ifr">
			<div class="form-group" style="margin-bottom: 0px;border-bottom: 0px solid #f6f6f6;">
				<div class="head-jnx" onclick="record()">
					<img src="../img/fanhui@3x.png"  />
					<p>停奶</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">耳号：<span style="color: red">*</span></label>
				<div class="col-xs-7">
					<select name="cowId" id="cowId"  class="selectpicker form-control m-b" data-live-search="true" onchange="getMilkCutType()"  data-size="10" title="选择耳号"  required>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">停奶日期：<span style="color: red">*</span></label>
				<div class="col-xs-7">
					<div class="input-group date">
						<!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
						<input id="milkCutDate" type="text" onfocus=this.blur() onclick="dtPicker('milkCutDate')">
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">复核人：</label>
				<div class="col-xs-7">
					<select name="recheckMan" id="recheckMan" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" >
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">停奶员：<span style="color: red">*</span></label>
				<div class="col-xs-7">
					<select name="milkCuter" id="milkCuter" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" required>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">停奶类型：</label>
				<div class="col-xs-7">
					<input  id="milkCutTypeText" class="form-control" type="text" readonly="readonly" >
					<input name="milkCutType" id="milkCutType" class="form-control" type="text" readonly="readonly" style="display: none">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">新栋舍：</label>
				<div class="col-xs-7">
					<select name="newCowHouseId" id="newCowHouseId" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" >
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">停奶药编号：</label>
				<div class="col-xs-7">
					<input name="milkCutDrugCode" class="form-control" type="text" placeholder="请输入">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">停奶药：</label>
				<div class="col-xs-7">
					<select name="milkCutDrug" id="milkCutDrug" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;">
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">生产批号：</label>
				<div class="col-xs-7">
					<input name="batchNumber" class="form-control" type="text" placeholder="请输入" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">使用量：</label>
				<div class="col-xs-7">
					<input name="apply" class="form-control" type="text" placeholder="请输入" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">提前停奶原因：</label>
				<div class="col-xs-7">
					<select name="earlyMilkCut" id="earlyMilkCut" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;">
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">推迟停奶原因：</label>
				<div class="col-xs-7">
					<select name="delayMilkCut" id="delayMilkCut" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;">
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">未孕停奶原因：</label>
				<div class="col-xs-7">
					<select name="unpregnantMilkCut" id="unpregnantMilkCut" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" >
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">臆乳-左前：</label>
				<div class="col-xs-7">
					<select name="chestLeftFront" id="chestLeftFront" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" >
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">臆乳-右前：</label>
				<div class="col-xs-7">
					<select name="chestRightFront" id="chestRightFront" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" >
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">臆乳-左后：</label>
				<div class="col-xs-7">
					<select name="chestLeftBehind" id="chestLeftBehind" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" >
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">臆乳-右后：</label>
				<div class="col-xs-7">
					<select name="chestRightBehind" id="chestRightBehind" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" >
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">预产期：</label>
				<div class="col-xs-7">
					<div class="input-group date">
						<!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
						<input id="projectedCalvingDate" type="text" onfocus=this.blur() onclick="dtPicker('projectedCalvingDate')" placeholder="请选择">
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">距产犊天数：</label>
				<div class="col-xs-7">
					<input name="daysFromCalving" class="form-control" type="text" placeholder="请输入" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">班次1：</label>
				<div class="col-xs-7">
					<input name="flight1" class="form-control" type="text" placeholder="请输入">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">班次2：</label>
				<div class="col-xs-7">
					<input name="flight2" class="form-control" type="text" placeholder="请输入" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">班次3：</label>
				<div class="col-xs-7">
					<input name="flight3" class="form-control" type="text" placeholder="请输入" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">班次4：</label>
				<div class="col-xs-7">
					<input name="flight4" class="form-control" type="text" placeholder="请输入" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">日产量：</label>
				<div class="col-xs-7">
					<input name="dailyProduction" class="form-control" type="text" placeholder="请输入" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">测奶日期：</label>
				<div class="col-xs-7">
					<div class="input-group date">
						<!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
						<input id="milkTestDate" type="text" onfocus=this.blur()onclick="dtPicker('milkTestDate')" placeholder="请选择">
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">配种日期：</label>
				<div class="col-xs-7">
					<div class="input-group date">
						<!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
						<input id="breedingDate" type="text" onfocus=this.blur() onclick="dtPicker('breedingDate')" placeholder="请选择">
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-4 control-label">备注：</label>
				<div class="col-xs-7">
					<input name="remake" class="form-control" type="text" placeholder="请输入">
				</div>
			</div>
			<div class="form-group">
				<div style="width: 320px; margin: auto;">
					<div class="quxiao-btn" style="margin-right: 15px;" onclick="record()">取消</div>
					<input type="submit" value="保存信息" class="quxiao-btn" style="background: #0078fb; color: #FFFFFF;border-radius: 55px;" >
					<div class="clear"></div>
				</div>
			</div>
		</form>
	</div>
	<iframe name='ifr' id="ifr" style='display: none;'></iframe><!--表单提交防止刷新-->
	<script src="../js/bootstrap.min.js"></script>
	<script src="../bootstrap-select/bootstrap-select.js"></script>
	<script>
		window.onload=breedLoad();
		function breedLoad() {//获得下拉数据
			var resultData = JSON.parse(localStorage.getItem('addmilkcutdata'));
			breedHtml(resultData.data);
			$("#milkCutDate").val(getDateNow());
		}
		$("#form-milkcut-add").submit(function () {
			map={};
			map=$('#form-milkcut-add').serializeObject();
			map.url="addmilkcut";
			map.overbit=$("#CowId option:selected").text();
		 	var resultData=ajaxRequestPostSubmit(map);
			if (resultData.head.info == "增加成功") {
				setTimeout(function () {
					record();
				}, 1000);
			}
		});
		function loadSelect(id,data,code,name,userName) {
			$("#"+id).html("");
			$("#"+id).append("<option value=''>请选择</option>");
			for (i=0;i<data.length;i++){//
				var str='';
				if(userName != null && data[i][name] == userName){
					str='<option value="'+data[i][code]+'" selected>'+data[i][name]+'</option>';
				}else{
					str='<option value="'+data[i][code]+'">'+data[i][name]+'</option>';
				}
				$("#"+id).append(str);
			}
		}
		function breedHtml(resultData) {//加载下拉框
			var overbitList=resultData.overbitList;//耳号
			loadSelect('cowId',overbitList,'cow_id','overbit');
			var milkCuterList=resultData.milkCuterList;//复核人
			var userName = resultData.realName;
			loadSelect('recheckMan',milkCuterList,'user_id','real_name',userName);
			loadSelect('milkCuter',milkCuterList,'user_id','real_name',userName);
			var cowHouseList=resultData.cowHouseList;//牛舍
			loadSelect('newCowHouseId',cowHouseList,'cowHouseId','cowHouseName');
			var cutDrugList=resultData.cutDrugList;//停奶药
			loadSelect('milkCutDrug',cutDrugList,'code','name');
			var earlyMilkCutList=resultData.earlyMilkCutList;//提前停奶原因
			loadSelect('earlyMilkCut',earlyMilkCutList,'code','name');
			var delayMilkCutList=resultData.delayMilkCutList;
			loadSelect('delayMilkCut',delayMilkCutList,'code','name');//推迟停奶原因
			var unpregnantMilkCut=resultData.unpregnantMilkCut;
			loadSelect('unpregnantMilkCut',unpregnantMilkCut,'code','name');//未孕停奶原因
			var chestLeftFrontList=resultData.chestLeftFrontList;
			loadSelect('chestLeftFront',chestLeftFrontList,'code','name');//臆乳-左前
			loadSelect('chestRightFront',chestLeftFrontList,'code','name');//臆乳-右前
			loadSelect('chestLeftBehind',chestLeftFrontList,'code','name');//臆乳-左后
			loadSelect('chestRightBehind',chestLeftFrontList,'code','name');//臆乳-右后
			$('.selectpicker').selectpicker('refresh');
		}
		function record() {//返回记录
			window.location = "../记录.html";
		}


	  function getMilkCutType() {
	  	var cowId = $("#cowId").val();
        var milkCutDate =$("#milkCutDate").val();
        var map={}
        map.cowId = cowId;
        map.milkCutDate = milkCutDate;
        map.url="getMilkCutType";
        if(cowId != null && cowId != "" && milkCutDate != null && milkCutDate != ""){
			var resultData=ajaxRequestPost(map);
			if(resultData.data.milkcutTypeList.length > 0){
				$("#milkCutTypeText").val(resultData.data.milkcutTypeList[0].stopmilkdate);
				$("#milkCutType").val(resultData.data.milkcutTypeList[0].code);
			}else{
				$("#milkCutType").val("");
				$("#milkCutTypeText").val("");
			}
        }
    }
	
	</script>
	</body>

</html>